package d02_Callable;

import java.util.concurrent.*;

public class Tets {
    public static void main(String[] args) {

        ExecutorService pool=new ThreadPoolExecutor(
                2,//正式工
                5,//最大线程数临时工加上正式工
                3,//临时工多久会被开除
                TimeUnit.SECONDS,//
                new ArrayBlockingQueue<>(3),//队列数为3
                Executors.defaultThreadFactory(),//HR
//                new ThreadPoolExecutor.AbortPolicy()//HR的应对策略
                new ThreadPoolExecutor.CallerRunsPolicy()//

                );
        pool.execute(()->{
            System.out.println("服务员1：在干活");
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        });
        System.out.println("主线程在干活");
    }
}
